package com.lianxi

/**
  * Created by adengdeng on 2017/8/6 
  */
object Lx2 {

  def main(args: Array[String]): Unit = {

    val a = Array(1, 2, 3, 4, 5)
    //数组中的元素顺序改变，左右互换
   for (i <- 0 until(a.length - 1, 2)) {
      val t = a(i)
      a(i) = a(i + 1)
      a(i + 1) = t
    }

    println(a.mkString(" "))
  }
}
